package state.socket;

public class Handle implements DataReceiveListener {
  private FlowManager flowManager = new FlowManager();

  public void registerFlow(int header, DataReceiveListener listener) {
    flowManager.put(new Integer(header), listener);
  }

  public void removeFlow(int header) {
    flowManager.remove(new Integer(header));
  }

  public void onConnectDone() {
  }

  public void onConnectFail() {
  }

  public void onDisconnect() {
  }

  public final void onRecieveData(DataPackage dataPackage) {
    if (flowManager.isMatch(dataPackage.getHeader())) {
      flowManager.execute(dataPackage);
    } else {
      processPackage(dataPackage);
    }
  }

  public void processPackage(DataPackage dataPackage) {
  }
}
